#include <iostream>
#include <vector>
#include <utility>
#include <cstdlib>
#include <ctime>

void sortArray(int idx, std::vector<int>& v)
{
    int min = v[idx];
    int minidx = idx;

    for (int j = idx; j < v.size(); j++) {
        if (v[j] < min) {
            min = v[j];
            minidx = j;
        }
    }
    std::swap(v[idx], v[minidx]);
}

int main(void)
{
    int n;
    std::vector<int> arr;
    
    std::cout << "Please enter the number of randam numbers you want to sort:";
    std::cin >> n;

    std::srand(std::time(nullptr));

    std::cout << "Numbers before sort:" << std::endl;
    for (int i = 0; i < n; i++) {
        int num = std::rand() % 100;
        arr.push_back(num);
        std::cout << num << " ";
    }
    std::cout << std::endl;

    for (int i = 0; i < n - 1; i++) {
        sortArray(i, arr);
    }

    std::cout << "Numbers after sort" << std::endl;
    for (std::vector<int>::iterator it = arr.begin(); it != arr.end(); it++) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    return 0;
}